package fr.univ.surveyonline.result;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import fr.univ.surveyonline.datastore.DatastoreKeyCompositeField;
import fr.univ.surveyonline.datastore.PMF;

@PersistenceCapable(identityType = IdentityType.DATASTORE)
public class ResultModel {
	// ATTRIBUTS
	@PrimaryKey
	@Persistent
	private String key;
	
	@Persistent
	private String analyse;
	
	@Persistent
	private Boolean isObservable;
	
	public ResultModel(DatastoreKeyCompositeField keyCompositeField) {
		this.key = keyCompositeField.toString();
		this.analyse = "";
		this.isObservable = true;
	}
	
	// GETTERS AND SETTERS
	public String getKeyCompositeField() {
		return key;
	}

	public String getAnalyse() {
		return analyse;
	}

	public void setAnalyse(String analyse) {
		this.analyse = analyse;
	}

	public Boolean isObservable() {
		return isObservable;
	}

	public void setObservable(boolean isObservable) {
		this.isObservable = isObservable;
	}
	
	public static ResultModel getResultModel(String keyCompositeField) {
		return (ResultModel) PMF.getElementById(ResultModel.class, keyCompositeField);
	}
}
